using UnityEngine;
using UnityEngine.UI;

public class Setting : MonoBehaviour
{
	public Canvas canvas;

	public Slider audioSlider;

	public AudioClip audioSliderAudio;

	public AudioSource audioSource;

	public float audioListenerVolume;

	private void Start()
	{
		audioSlider.value = PlayerPrefs.GetFloat("audioListenerVolume") * audioSlider.maxValue;
		audioSlider.onValueChanged.AddListener(delegate
		{
			AudioListener.volume = audioSlider.value / audioSlider.maxValue;
			audioSource.PlayOneShot(audioSliderAudio);
		});
	}

	private void Update()
	{
	}

	public void Open()
	{
		canvas.enabled = true;
		canvas.gameObject.SetActive(value: true);
	}

	public void Apply()
	{
		PlayerPrefs.SetFloat("audioListenerVolume", AudioListener.volume);
		Close();
	}

	public void Close()
	{
		canvas.enabled = false;
		Invoke("Sleep", 1f);
	}

	public void Sleep()
	{
		canvas.gameObject.SetActive(value: false);
	}
}
